//
//  AddressCell.m
//  efairy
//
//  Created by 李锋 on 2019/1/9.
//  Copyright © 2019年 East. All rights reserved.
//

#import "AddressCell.h"
#import "AreaAddressModel.h"

@implementation AddressCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if(selected){
        if(_chooseImage){
            _addressName.textColor = ColorFromRGB(0x282449);
            _chooseImage.hidden=NO;
        }
    }else{
        if(_chooseImage){
             _addressName.textColor = ColorFromRGB(0x666666);
            _chooseImage.hidden=YES;
        }
    }
}



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self initView];
    }
    return self;
}

-(void) initView{
    _chooseImage = [[UIImageView alloc]init];//图标
    _chooseImage.image=[UIImage imageNamed:@"icon_select_right"];
    
    _addressName = [[UILabel alloc]init];
    _addressName.font=[UIFont systemFontOfSize:15.0];
    
    _addressName.textColor = ColorFromRGB(0x666666);
    
    [self.contentView sd_addSubviews:@[_chooseImage,_addressName]];
    
    _addressName.sd_layout
    .heightIs(15)
    .leftSpaceToView(self.contentView, 24)
    .rightSpaceToView(self.contentView, 50)
    .topSpaceToView(self.contentView, 15);
    
    _chooseImage.sd_layout.widthIs(14.1).heightIs(8)
    .rightSpaceToView(self.contentView, 16)
    .topSpaceToView(self.contentView, 18.5);
    
    [self setupAutoHeightWithBottomView:_addressName bottomMargin:10];
}

-(void)configViewWithItem:(NSObject *)item{
//    _chooseImage.hidden=YES;
    if (item != nil && [item isKindOfClass:[ProvinceModel class]]) {
        _addressName.text=((ProvinceModel*)item).efairyprovince_name;

    }else  if (item != nil && [item isKindOfClass:[CityModel class]]) {
        _addressName.text=((CityModel*)item).efairycity_name;

    }else  if (item != nil && [item isKindOfClass:[DistrictModel class]]) {
        _addressName.text=((DistrictModel*)item).efairydistrict_name;

    }else  if (item != nil && [item isKindOfClass:[TownshipModel class]]) {
        _addressName.text=((TownshipModel*)item).efairytownship_name;
    }
    
}
@end
